package chapter2;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class hwf1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String su = input.next();
        Map<Character,Integer> map = new HashMap<>();
        char[] strings = su.toCharArray();
        for (char s : strings) {
            if (map.get(s) != null) {
               map.put(s,map.get(s)+1);
               continue;
            }
            map.put(s,1);
        }

        for (Map.Entry<Character,Integer> show: map.entrySet()) {
            System.out.println("key = " + show.getKey() + ", value = " + show.getValue());
        }


    }
}
